/*
 * Copyright (c) 2022  by Junzhao
 * THIS FILE IS PART OF JAVASE Song Huongkang PROJECT
 * All Rights Reserved.
 */

package 学习.上.创建对象与调用;
/**
 * @description
 * @param
 * @return
 * @author 俊昭
 * @date 2022/3/16
 * 创建的对象没有显式的变量名 即为匿名
 * 匿名对象只能调用一次
 * 使用
*/
public class InstanceTest {
    public static void main(String[] args) {
        Phone p1 = new Phone();
        p1.sendEmail();
        p1.price= 4999;
        p1.playGame();
        p1.showPrice();
        System.out.println("****************");

        PhoneMall phoneMall = new PhoneMall();
        phoneMall.show(new Phone());
        System.out.println("****************");

        //匿名对象
        new Phone().sendEmail();
        new Phone().playGame();
        System.out.println("****************");
        new Phone().price = 2313;
        new Phone().showPrice();

    }
}
class PhoneMall{
    public void show(Phone phone){
        phone.showPrice();
        phone.playGame();
    }
}
class Phone{
    double price;//价格

    public void sendEmail(){
        System.out.println("发送邮件");
    }

    public void playGame(){
        System.out.println("玩游戏");
    }
    public void showPrice(){
        System.out.println("手机的价格是：" + price);
    }
}